package com.itcast.home_work.pet_manager;

import java.util.ArrayList;


interface BuyPetInterface <T> {
    public void buyPet(T t);
}

public class Test {
    public static void main(String[] args) {
        // 列表做宠物店
        ArrayList<Pet> pets = new ArrayList<>();

        pets.add(new Bird());
        pets.add(new Cat());
        pets.add(new Dog());

        System.out.println(pets);

        // 买宠物
        BuyPetInterface buyPetInterface = new BuyPetInterface<Pet>() {
            @Override
            public void buyPet(Pet p) {
                switch (p.getType()) {
                    case CAT:
                        System.out.println("买了猫");
                        break;
                    case DOG:
                        System.out.println("买了狗");
                        break;
                    case BIRD:
                        System.out.println("买了鸟");
                        break;
                }
            }
        };

        buyPetInterface.buyPet(new Cat());
        buyPetInterface.buyPet(new Dog());
        buyPetInterface.buyPet(new Bird());
    }
}
